From: Owen W. Taylor Date: Sat, 29 Aug 2009 16:31:15 +0000 (-0400) Subject: ShellButtonBox: Use default handlers, not self-connections X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~10990 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=0e3cea41e0aa75b3e9603429215009f65d61144d;p=gnome-shell.git ShellButtonBox: Use default handlers, not self-connections There's seldom a good justification for connecting to signals on yourself rather than using the default handler slots in the class. But in particular using the default handler slots means that an application can connect to ::button-press-event and get in before the default handling, to implement a button that does something on press. http://bugzilla.gnome.org/show_bug.cgi?id=593503 --- diff --git a/src/shell-button-box.c b/src/shell-button-box.c index 25808a45a..56dd94410 100644 --- a/src/shell-button-box.c +++ b/src/shell-button-box.c @@ -79,13 +79,14 @@ shell_button_box_contains (ShellButtonBox *box, } static gboolean -shell_button_box_on_enter (ShellButtonBox *box, - ClutterEvent *event, - gpointer user_data) +shell_button_box_enter_event (ClutterActor *actor, + ClutterCrossingEvent *event) { - if (shell_button_box_contains (box, event->crossing.related)) + ShellButtonBox *box = SHELL_BUTTON_BOX (actor); + + if (shell_button_box_contains (box, event->related)) return TRUE; - if (!shell_button_box_contains (box, clutter_event_get_source (event))) + if (!shell_button_box_contains (box, event->source)) return TRUE; set_hover (box, TRUE); @@ -96,11 +97,12 @@ shell_button_box_on_enter (ShellButtonBox *box, } static gboolean -shell_button_box_on_leave (ShellButtonBox *box, - ClutterEvent *event, - gpointer user_data) +shell_button_box_leave_event (ClutterActor *actor, + ClutterCrossingEvent *event) { - if (shell_button_box_contains (box, event->crossing.related)) + ShellButtonBox *box = SHELL_BUTTON_BOX (actor); + + if (shell_button_box_contains (box, event->related)) return TRUE; set_hover (box, FALSE); @@ -110,17 +112,15 @@ shell_button_box_on_leave (ShellButtonBox *box, } static gboolean -shell_button_box_on_press (ShellButtonBox *box, - ClutterEvent *event, - gpointer user_data) +shell_button_box_button_press_event (ClutterActor *actor, + ClutterButtonEvent *event) { - ClutterActor *source; + ShellButtonBox *box = SHELL_BUTTON_BOX (actor); if (box->priv->held) return TRUE; - source = clutter_event_get_source (event); - if (!shell_button_box_contains (box, source)) + if (!shell_button_box_contains (box, event->source)) return FALSE; box->priv->held = TRUE; @@ -132,21 +132,18 @@ shell_button_box_on_press (ShellButtonBox *box, } static gboolean -shell_button_box_on_release (ShellButtonBox *box, - ClutterEvent *event, - gpointer user_data) +shell_button_box_button_release_event (ClutterActor *actor, + ClutterButtonEvent *event) { - ClutterActor *source; + ShellButtonBox *box = SHELL_BUTTON_BOX (actor); if (!box->priv->held) return TRUE; - source = clutter_event_get_source (event); - box->priv->held = FALSE; clutter_ungrab_pointer (); - if (!shell_button_box_contains (box, source)) + if (!shell_button_box_contains (box, event->source)) return FALSE; set_pressed (box, FALSE); @@ -204,10 +201,16 @@ static void shell_button_box_class_init (ShellButtonBoxClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); gobject_class->get_property = shell_button_box_get_property; gobject_class->set_property = shell_button_box_set_property; + actor_class->enter_event = shell_button_box_enter_event; + actor_class->leave_event = shell_button_box_leave_event; + actor_class->button_press_event = shell_button_box_button_press_event; + actor_class->button_release_event = shell_button_box_button_release_event; + /** * ShellButtonBox::activate * @box: The #ShellButtonBox @@ -275,9 +278,4 @@ shell_button_box_init (ShellButtonBox *self) { self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, SHELL_TYPE_BUTTON_BOX, ShellButtonBoxPrivate); - - g_signal_connect (G_OBJECT (self), "enter-event", G_CALLBACK(shell_button_box_on_enter), NULL); - g_signal_connect (G_OBJECT (self), "leave-event", G_CALLBACK(shell_button_box_on_leave), NULL); - g_signal_connect (G_OBJECT (self), "button-press-event", G_CALLBACK(shell_button_box_on_press), NULL); - g_signal_connect (G_OBJECT (self), "button-release-event", G_CALLBACK(shell_button_box_on_release), NULL); }